package com.nmsl.medicine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.medicine.domain.StorageOutDetailRecord;
import com.nmsl.medicine.service.IStorageOutDetailRecordService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 出库记录详情Controller
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/medicine/outrecordinfo")
public class StorageOutDetailRecordController extends BaseController
{
    @Autowired
    private IStorageOutDetailRecordService storageOutDetailRecordService;

    /**
     * 查询出库记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorageOutDetailRecord storageOutDetailRecord)
    {

        System.out.println(storageOutDetailRecord);
        startPage();
        List<StorageOutDetailRecord> list = storageOutDetailRecordService.selectStorageOutDetailRecordList(storageOutDetailRecord);
        return getDataTable(list);
    }

    /**
     * 导出出库记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:export')")
    @Log(title = "出库记录详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StorageOutDetailRecord storageOutDetailRecord)
    {
        List<StorageOutDetailRecord> list = storageOutDetailRecordService.selectStorageOutDetailRecordList(storageOutDetailRecord);
        ExcelUtil<StorageOutDetailRecord> util = new ExcelUtil<StorageOutDetailRecord>(StorageOutDetailRecord.class);
        util.exportExcel(response, list, "出库记录详情数据");
    }

    /**
     * 获取出库记录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:query')")
    @GetMapping(value = "/{storageOutDetailId}")
    public AjaxResult getInfo(@PathVariable("storageOutDetailId") Long storageOutDetailId)
    {
        return success(storageOutDetailRecordService.selectStorageOutDetailRecordByStorageOutDetailId(storageOutDetailId));
    }

    /**
     * 新增出库记录详情
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:add')")
    @Log(title = "出库记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorageOutDetailRecord storageOutDetailRecord)
    {
        return toAjax(storageOutDetailRecordService.insertStorageOutDetailRecord(storageOutDetailRecord));
    }

    /**
     * 修改出库记录详情
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:edit')")
    @Log(title = "出库记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorageOutDetailRecord storageOutDetailRecord)
    {
        return toAjax(storageOutDetailRecordService.updateStorageOutDetailRecord(storageOutDetailRecord));
    }

    /**
     * 删除出库记录详情
     */
    @PreAuthorize("@ss.hasPermi('medicine:outrecordinfo:remove')")
    @Log(title = "出库记录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{storageOutDetailIds}")
    public AjaxResult remove(@PathVariable Long[] storageOutDetailIds)
    {
        return toAjax(storageOutDetailRecordService.deleteStorageOutDetailRecordByStorageOutDetailIds(storageOutDetailIds));
    }
}
